package com.pactera.jep.service.yapin.eval.model.controller;

import com.pactera.jep.web.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import com.pactera.jep.orm.Filter;
import com.pactera.jep.orm.Order;
import com.pactera.jep.orm.Page;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pactera.jep.core.exception.ServiceException;
import com.pactera.jep.web.controller.CrudController;
import org.springframework.web.bind.annotation.*;

import com.pactera.jep.service.yapin.eval.model.model.ValModelFactor;
import com.pactera.jep.service.yapin.eval.model.service.ValModelFactorService;


/**
 *
 * @Author YouName
 * @Date 2020-7-20 14:00:41
 */
@RestController
@RequestMapping("/valmodelfactor")
@Api(description = "房屋估值模型与可比因素对照表")
public class ValModelFactorController extends CrudController<ValModelFactor> {

    @Autowired
    ValModelFactorService valModelFactorService;

    @GetMapping("/{id}")
    @ApiOperation("查询房屋估值模型与可比因素对照表")
    public Result get(@PathVariable("id") String modelFactorId) {
        return Result.success(valModelFactorService.get(modelFactorId));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除房屋估值模型与可比因素对照表")
    public Result delete(@PathVariable("id") String modelFactorId) {
        return Result.success(valModelFactorService.deleteByPrimaryKey(modelFactorId));
    }

    @PostMapping("/save")
    @ApiOperation("插入房屋估值模型与可比因素对照表")
    public Result insert(@RequestBody ValModelFactor valModelFactor) {
        return Result.success(valModelFactorService.insert(valModelFactor));
    }

    @PostMapping("/update")
    @ApiOperation("更新房屋估值模型与可比因素对照表")
    public Result update(@RequestBody ValModelFactor valModelFactor) {
        return Result.success(valModelFactorService.update(valModelFactor));
    }

    /**
     * 为列表页面做数据准备
     */
    @Override
    protected void prepareQuery(Page<ValModelFactor> page, List<Filter> filters, List<Order> orders, HttpServletRequest    request) {
        valModelFactorService.query(page, filters, orders);
    }
}
